/*
 * StringTokeniserPanel.java
 *
 * Created on 13 July 2006, 21:48
 */

package andyr.jtokeniser.gui;

/**
 *
 * @author  Andy Roberts
 */
public class StringTokeniserPanel extends javax.swing.JPanel {
    
    /** Creates new form StringTokeniserPanel */
    public StringTokeniserPanel() {
        initComponents();
    }
    
    public boolean isKeepDelim() {
        return chkKeepDelim.isSelected();
    }
    
    public String getDelimiter() {
        String delim = txtDelim.getText();
        delim = delim.replace("\\n", "\n");
        delim = delim.replace("\\r", "\r");
        delim = delim.replace("\\t", "\t");
        delim = delim.replace("\\f", "\f");
        return delim;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        lblKeepDelim = new javax.swing.JLabel();
        chkKeepDelim = new javax.swing.JCheckBox();
        lblDelim = new javax.swing.JLabel();
        txtDelim = new javax.swing.JTextField();

        lblKeepDelim.setText("Keep delimiter");

        chkKeepDelim.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        chkKeepDelim.setMargin(new java.awt.Insets(0, 0, 0, 0));

        lblDelim.setText("Delimiter");

        txtDelim.setText(" \\t\\n\\r\\f");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(lblDelim)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(txtDelim, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE))
                    .add(layout.createSequentialGroup()
                        .add(lblKeepDelim)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(chkKeepDelim)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblDelim)
                    .add(txtDelim, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblKeepDelim)
                    .add(chkKeepDelim))
                .addContainerGap(250, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox chkKeepDelim;
    private javax.swing.JLabel lblDelim;
    private javax.swing.JLabel lblKeepDelim;
    private javax.swing.JTextField txtDelim;
    // End of variables declaration//GEN-END:variables
    
}
